package ccy.ccykills.papi;

import ccy.ccykills.config.KillData;
import ccy.ccykills.config.PlayerInfo;
import ccy.ccylibrary.papi.PapiExpansion;
import ccy.ccylibrary.plugin.annotation.Papi;
import ccy.ccykills.config.CcyConfig;
import org.bukkit.OfflinePlayer;

@Papi
public class ShowTotalPapi extends PapiExpansion {

    public String getIdentifier() {
        return "ccykill";
    }

    public String onRequest(OfflinePlayer offlinePlayer, String s) {
        if (s.equals("value")) {
            return CcyConfig.config.playerNumMap.containsKey(offlinePlayer.getUniqueId()) ? String.valueOf((CcyConfig.config.playerNumMap.get(offlinePlayer.getUniqueId())).getValue()) : "0";
        } else if (s.equals("rank")) {
            return CcyConfig.config.mapPlayer_total.containsKey(offlinePlayer.getName()) ? String.valueOf(CcyConfig.config.mapPlayer_total.get(offlinePlayer.getName())) : CcyConfig.config.RankOut;
        } else {
            if (s.contains("player_name_")) {
                int num = Integer.parseInt(s.replace("player_name_", ""));
                if (CcyConfig.config.mapRank_total.containsKey(num)) {
                    return (CcyConfig.config.mapRank_total.get(num)).getName();
                }
            } else if (s.contains("player_value_")) {
                int num = Integer.parseInt(s.replace("player_value_", ""));
                if (CcyConfig.config.mapRank_total.containsKey(num)) {
                    return String.valueOf((CcyConfig.config.mapRank_total.get(num)).getValue());
                }
            }

            return "-";
        }
    }
}
